package com.aeromedia.testcustomapplication.recyclerVIew;

import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;

import com.aeromedia.testcustomapplication.CustomServiceUser;
import com.aeromedia.testcustomapplication.R;


public class CustomServiceAdapter extends CommonAdapter<CustomServiceUser> {
    public CustomServiceAdapter(Context context) {
        super(context, R.layout.custom_service_item);
    }

    @Override
    protected void bindData(CommonHolder holder, CustomServiceUser data) {
        CommonHolder commonHolder = holder.setText(R.id.user_info, data.userName)
                ;
        if (data.state == CustomServiceUser.State.ONLINE) {
            Log.d(TAG, "bindData: data.state == CustomServiceUser.State.ONLINE");
            commonHolder
                    .setTextColor(R.id.user_info, R.color.black)
                    .setTextColor(R.id.text_view_state, R.color.color_green)
                    .setText(R.id.text_view_state, "空闲")
                    .setImage(R.id.icon_user, R.mipmap.service_person_idle)
                    .setBackGround(R.id.custom_service_item_root, new ChangeBackground() {
                        @Override
                        public void change(View view) {
                            view.setBackgroundColor(Color.WHITE);
                        }
                    })
                    .setTextDrawable(R.id.text_view_state, R.drawable.idle_state)
            ;
        } else {
            Log.d(TAG, "bindData: data.state == CustomServiceUser.State.OFFLINE");
            commonHolder
                    .setTextColor(R.id.user_info, R.color.busy_color_custom)
                    .setTextColor(R.id.text_view_state, R.color.busy_color)
                    .setText(R.id.text_view_state, "正忙")
                    .setImage(R.id.icon_user, R.mipmap.service_person_busy)
//                    .setBackGround(R.id.custom_service_item_root, new ChangeBackground() {
//                        @Override
//                        public void change(View view) {
//                            view.setBackgroundColor(Color.parseColor("#FFD6D2D2"));
//                        }
//                    })
                    .setTextDrawable(R.id.text_view_state, R.drawable.busy_state_light);
        }

    }

    private static final String TAG = "CustomServiceAdapter";
}
